package com.neuedu.cockpit.service.impl;

import com.neuedu.cockpit.domain.CarMileage;
import com.neuedu.cockpit.mapper.CarMileageMapper;
import com.neuedu.cockpit.service.ICarMileageService;
import com.neuedu.common.utils.DateUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * 车辆状态Service业务层处理
 *
 * @author neuedu
 * @date 2024-07-08
 */
@Service
public class CarMileageServiceImpl implements ICarMileageService {
    @Autowired
    private CarMileageMapper carMileageMapper;

    /**
     * 查询车辆状态
     *
     * @param id 车辆状态主键
     * @return 车辆状态
     */
    @Override
    public CarMileage selectCarMileageById(Long id) {
        return carMileageMapper.selectCarMileageById(id);
    }

    /**
     * 查询车辆状态列表
     *
     * @param carMileage 车辆状态
     * @return 车辆状态
     */
    @Override
    public List<CarMileage> selectCarMileageList(CarMileage carMileage) {
        return carMileageMapper.selectCarMileageList(carMileage);
    }

    /**
     * 新增车辆状态
     *
     * @param carMileage 车辆状态
     * @return 结果
     */
    @Override
    public int insertCarMileage(CarMileage carMileage) {
        carMileage.setCreateTime(DateUtils.getNowDate());
        return carMileageMapper.insertCarMileage(carMileage);
    }

    /**
     * 修改车辆状态
     *
     * @param carMileage 车辆状态
     * @return 结果
     */
    @Override
    public int updateCarMileage(CarMileage carMileage) {
        return carMileageMapper.updateCarMileage(carMileage);
    }

    /**
     * 批量删除车辆状态
     *
     * @param ids 需要删除的车辆状态主键
     * @return 结果
     */
    @Override
    public int deleteCarMileageByIds(Long[] ids) {
        return carMileageMapper.deleteCarMileageByIds(ids);
    }

    /**
     * 删除车辆状态信息
     *
     * @param id 车辆状态主键
     * @return 结果
     */
    @Override
    public int deleteCarMileageById(Long id) {
        return carMileageMapper.deleteCarMileageById(id);
    }

    /**
     * 统计最近30天里程情况
     *
     * @return
     */
    @Override
    public List stat() {
        return carMileageMapper.stat();
    }
}
